﻿using System;

namespace MySql.Simple.Mapper
{
    public static class ToMySqlSyntaxExtension
    {
        public static string ToMySqlSyntax(this object value)
        {
            var syntax = string.Empty;

            if (value == null)
            {
                syntax = "NULL";
            }
            else if (value is String)
            {
                syntax += @"""" + value + @"""";
            }
            else if (value is DateTime)
            {
                syntax += string.Format("'{0:yyyy-MM-dd hh:mm:ss}'", value);
            }
            else
            {
                syntax += value;
            }

            return syntax;
        }
    }
}
